<template>
	<view class="main_container">
		<u-tabs :list="list1" @click="click"></u-tabs>
		<u--form :model="queryParams">
			<u-form-item>
				<u--input v-model="queryParams.name" placeholder="请输入关键字搜索"></u--input>
				<u-button slot="right" text="搜索" type="primary" @click="goSearch"></u-button>
			</u-form-item>
		</u--form>
		<scroll-view class="member_lsit" scroll-y="true" :style="'height:100%'" enable-flex @scrolltolower="scrollToLower()" @scrolltoupper="updateOrderInfo()">
			<view v-show="item.personName" class="video_item" v-for="(item, index) in memberList" :key="index" @click="rencaiDetail(memberList[index])">
				<!-- <image class="video_img" :src="item.image"></image> -->
				<view class="video_content">
					<view style="width: 100%; display: flex;">
						<text class="video_title">{{ item.personName }}</text>
						<text class="publicTime">人才类型：{{ getType(item.personType) }}</text>
					</view>
					<view style="width: 100%; margin-top: 18rpx; font-size: 28rpx; float: left">
						<text style="">入库时间：{{ item.warehousTime }}</text>
					</view>
					<view style="padding-right: 5rpx; width: 100%; margin-top: 18rpx; font-size: 28rpx; float: left">
						<text style="display: inline-block; width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;">单位名称：{{ item.companyName || '' }}</text>
					</view>
				</view>
			</view>
			<view class="no-data" v-if="memberList.length == 0" @click="listTechperson()">
			 {{noData}}
			</view>
		</scroll-view>
	</view>
</template>

<script>
import env from '@/utils/env.js';
import * as techPerson from '@/api/source/kjrc/TECH_PERSON.js';
import * as dict from '@/api/system/dict/data.js';
import uniTag from '@/components/uni-tag/components/uni-tag/uni-tag.vue';

import { codeList } from '@/utils/code';
import { defineComponent } from 'vue';
export default {
	components: {
		uniTag
	},
	data() {
		return {
			title: '',
			memberList: [],
			currentType: 0,
			researchDirection: [],
			query: {
				pageSize: 10,
				pageNum: 1
			},
			total: 0,
			noData:'暂无数据',
			list1: [
				{
					name: '全部',
					value: null
				}
			],
			queryParams: {},
			personType: null
		};
	},
	onLoad(option) {
		this.listTechperson();
		uni.showLoading({});
		this.getDict();
	},
	methods: {
		goSearch() {
			this.query.pageNum = 1;
			this.memberList = [];
			this.listTechperson();
		},
		click(item) {
			console.log('item', item);
			this.personType = item.value;
			this.query.pageNum = 1;
			this.memberList = [];
			this.listTechperson();
		},
		getDict() {
			dict.getDicts('science_person_type').then((res) => {
				if (res.data && res.data.length > 0) {
					this.researchDirection = res.data;
					this.researchDirection.forEach((item) => {
						this.list1.push({
							name: item.dictLabel,
							value: item.dictValue
						});
					});
					console.log(this.researchDirection);
				}
			});
		},
		listTechperson() {
			this.noData = '加载中。。。'
			let data = this.query;
			if (this.queryParams.name) {
				data.personName = this.queryParams.name;
			} else {
				delete data.personName;
			}
			if (this.personType) {
				data.personType = this.personType;
			} else {
				delete data.personType;
			}
			techPerson.getPersonList(data).then((res) => {
				res.rows.forEach((v) => {
					v.warehousTime = v.warehousTime.substr(0, 10);
					this.memberList.push(v);
				});
				uni.hideLoading({});
				console.log(987321654, this.memberList);
				this.total = res.total;
				if(this.memberList.length===0){
					this.noData = '暂无数据，点击重试'
				}
			});
		},
		rencaiDetail(item) {
			uni.navigateTo({
				url: '/subpages/pages/detail/rencai_detail?id=' + item.id + '&type=' + item.personType
			});
		},
		getType(type) {
			var persontype = '';
			this.researchDirection.forEach((v) => {
				if (v.dictValue === type) persontype = v.dictLabel;
			});
			return persontype;
		},
		// 更新order
		updateOrderInfo(index) {
			let _this = this;
			if (_this.currentIndex == 0) {
				this.cgdjquery.pageNum = 1;
				this.memberList = [];
				_this.listTechperson();
			} else {
				this.cgzhquery.pageNum = 1;
				this.memberList = [];
				_this.listTechperson();
			}
		},
		// 滑到底部 加载更多
		scrollToLower() {
			console.log('222');
			let _this = this;
			if (_this.memberList.length < _this.total) {
				console.log('111');
				_this.query.pageNum = _this.query.pageNum + 1;
				_this.listTechperson();
			} else {
				console.log('333');
				uni.showToast({
					icon: 'none',
					title: '没有更多数据'
				});
			}
		}
	}
};
</script>

<style scoped>
.main_container {
	width: 100vw;
	height: 100vh;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	align-items: center;
	background-color: #e3e3e3;
}

.member_lsit {
	height: fit-content;
	width: 100%;
	padding-top: 1rpx;
	padding-bottom: 1rpx;
	background-color: #e3e3e3;
}

.video_item {
	height: 175rpx;
	width: 95%;
	padding: 20rpx;
	margin: 20rpx auto;
	border-radius: 10rpx;
	background-color: #fff;
	box-shadow: 5rpx 0rpx 10rpx #e3e3e3;
	overflow: hidden;
}

.video_img {
	margin-top: 25rpx;
	height: 190rpx;
	width: 180rpx;
	border-radius: 50%;
	margin-left: 30rpx;
	float: left;
}

.video_content {
	width: 90%;
	height: 140rpx;
	margin-left: 15rpx;
}

.video_title {
	width: 50%;
	display: inline-block;
	font-size: 33rpx;
	font-weight: 700;
	margin-top: 15rpx;
	overflow: hidden; /*超出部分隐藏*/
	white-space: nowrap; /*禁止换行*/
	text-overflow: ellipsis; /*省略号*/
}

.publicTime {
	width: 50%;
	font-size: 23rpx;
	color: darkred;
	margin-top: 15rpx;
	display: inline-block;
	overflow: hidden; /*超出部分隐藏*/
	white-space: nowrap; /*禁止换行*/
	text-overflow: ellipsis; /*省略号*/
}

.devideline {
	float: left;
	height: 0.3rpx;
	width: 100%;
	background-color: #eeeeee;
	margin-top: 15rpx;
	margin-bottom: 15rpx;
}
.no-data {
		width: 100%;
		height: 300rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		font-size: 32rpx;
		margin-top: 100rpx;
	}
	
	.no-data .no-data-img {
		width: 300rpx;
		height: 268rpx;
	}
</style>
